Skip to content

Add binding anchors; make profile-all use srcspan from anchors - #7730

Open
SeungheonOh wants to merge 2 commits into
masterfrom
sho/proileSrcspan
Open

Add binding anchors; make profile-all use srcspan from anchors#7730
SeungheonOh wants to merge 2 commits into
masterfrom
sho/proileSrcspan

Conversation

@SeungheonOh

Copy link
Copy Markdown
Collaborator

closes #7722

Added anchors to bindings; added anchors can be used in profile-all which is used for profiling and call tracing to mark function entrance/exit source span.

Previously, function entrance and exit source span was extracted from GHC.Var which only gave source span when the module was freshly compiled. When module was not compiled and cache was used from previous compilation, GHC.Var will not provide any source span. New anchor based source span fixes this and provide correct source span even when module compilation is cached.

@SeungheonOh SeungheonOh self-assigned this Apr 21, 2026
@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Execution Budget Golden Diff

253be44 (master) vs f399dce

output

plutus-tx-plugin/test/BuiltinList/NoCasing/9.12/unsafeUnconsOk.golden.eval

Metric Old New Δ%
CPU 452_913 516_913 +14.13%
Memory 1_964 2_364 +20.37%
Flat Size 35 42 +20.00%

plutus-tx-plugin/test/BuiltinList/NoCasing/9.6/unsafeUnconsOk.golden.eval

Metric Old New Δ%
CPU 452_913 516_913 +14.13%
Memory 1_964 2_364 +20.37%
Flat Size 35 42 +20.00%

plutus-tx-plugin/test/CallTrace/9.12/successfullEvaluationYieldsNoTraceLog.golden.eval

Metric Old New Δ%
CPU 1_621_088 1_669_088 +2.96%
Memory 8_192 8_492 +3.66%
Flat Size 452 454 +0.44%

plutus-tx-plugin/test/CallTrace/9.6/successfullEvaluationYieldsNoTraceLog.golden.eval

Metric Old New Δ%
CPU 1_621_088 1_669_088 +2.96%
Memory 8_192 8_492 +3.66%
Flat Size 452 454 +0.44%

plutus-tx-plugin/test/IsData/Budget/SoP/9.12/decodeA.golden.eval

Metric Old New Δ%
CPU 1_452_851 560_582 -61.42%
Memory 5_962 2_896 -51.43%
Flat Size 123 70 -43.09%

plutus-tx-plugin/test/IsData/Budget/SoP/9.12/decodeC.golden.eval

Metric Old New Δ%
CPU 2_226_823 725_790 -67.41%
Memory 8_568 3_298 -61.51%
Flat Size 122 69 -43.44%

plutus-tx-plugin/test/IsData/Budget/SoP/9.12/decodeMixedNone.golden.eval

Metric Old New Δ%
CPU 1_300_957 424_688 -67.36%
Memory 5_598 2_632 -52.98%
Flat Size 118 66 -44.07%

plutus-tx-plugin/test/IsData/Budget/SoP/9.12/decodeMixedTwo.golden.eval

Metric Old New Δ%
CPU 2_588_380 1_103_347 -57.37%
Memory 9_764 4_594 -52.95%
Flat Size 121 69 -42.98%

plutus-tx-plugin/test/IsData/Budget/SoP/9.12/decodePairA.golden.eval

Metric Old New Δ%
CPU 1_452_851 560_582 -61.42%
Memory 5_962 2_896 -51.43%
Flat Size 94 53 -43.62%

plutus-tx-plugin/test/IsData/Budget/SoP/9.12/decodePairB.golden.eval

Metric Old New Δ%
CPU 1_922_441 725_790 -62.25%
Memory 7_466 3_298 -55.83%
Flat Size 94 53 -43.62%

plutus-tx-plugin/test/IsData/Budget/SoP/9.12/decodeSingle.golden.eval

Metric Old New Δ%
CPU 1_452_851 560_582 -61.42%
Memory 5_962 2_896 -51.43%
Flat Size 68 39 -42.65%

plutus-tx-plugin/test/IsData/Budget/SoP/9.6/decodeA.golden.eval

Metric Old New Δ%
CPU 1_452_851 560_582 -61.42%
Memory 5_962 2_896 -51.43%
Flat Size 123 70 -43.09%

plutus-tx-plugin/test/IsData/Budget/SoP/9.6/decodeC.golden.eval

Metric Old New Δ%
CPU 2_226_823 725_790 -67.41%
Memory 8_568 3_298 -61.51%
Flat Size 122 69 -43.44%

plutus-tx-plugin/test/IsData/Budget/SoP/9.6/decodeMixedNone.golden.eval

Metric Old New Δ%
CPU 1_300_957 424_688 -67.36%
Memory 5_598 2_632 -52.98%
Flat Size 118 66 -44.07%

plutus-tx-plugin/test/IsData/Budget/SoP/9.6/decodeMixedTwo.golden.eval

Metric Old New Δ%
CPU 2_588_380 1_103_347 -57.37%
Memory 9_764 4_594 -52.95%
Flat Size 121 69 -42.98%

plutus-tx-plugin/test/IsData/Budget/SoP/9.6/decodePairA.golden.eval

Metric Old New Δ%
CPU 1_452_851 560_582 -61.42%
Memory 5_962 2_896 -51.43%
Flat Size 94 53 -43.62%

plutus-tx-plugin/test/IsData/Budget/SoP/9.6/decodePairB.golden.eval

Metric Old New Δ%
CPU 1_922_441 725_790 -62.25%
Memory 7_466 3_298 -55.83%
Flat Size 94 53 -43.62%

plutus-tx-plugin/test/IsData/Budget/SoP/9.6/decodeSingle.golden.eval

Metric Old New Δ%
CPU 1_452_851 560_582 -61.42%
Memory 5_962 2_896 -51.43%
Flat Size 68 39 -42.65%

This comment will get updated when changes are made.

@SeungheonOh SeungheonOh added the No Changelog Required Add this to skip the Changelog Check label Apr 21, 2026
anchor for every hoisted binding, so profile-trace output identifies which
function was entered (the span points to the binder, not an arbitrary
sub-expression). See issue #7722. -}
anchorBinding

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are using same anchor function that's being used for anchoring expressions. It's working okay at the moment, but maybe in the future we want to separate binding anchors with some other anchor function like bindingAnchor so that it can be distinguished more easily


{-| Find the first @anchor@-carried 'RealSrcSpan' anywhere inside a 'CoreExpr',
descending through applications, lambdas, lets, cases, casts, and ticks.
Useful when the immediate head of the expression is not an anchor call

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an example where the immediate head of the expression is not an anchor call, because it was hoisted?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking back, I don't think this is the case anymore after adding binding anchor.

@SeungheonOh
SeungheonOh requested a review from zliu41 July 8, 2026 13:30
@SeungheonOh

Copy link
Copy Markdown
Collaborator Author

I redid everything with a different approach:

instead of using original anchor, I created a new bindingAnchor specialized for creating anchors for definition bindings, which seems to work better.

@zliu41

zliu41 commented Jul 11, 2026

Copy link
Copy Markdown
Member

Does bindingAnchor also serve the same purpose as anchor, i.e., improving line number reporting in error messages? Or is it only useful in profiling mode?

@zliu41

zliu41 commented Jul 11, 2026

Copy link
Copy Markdown
Member

It would be useful to expand the Haddock for anchor and bindingAnchor, to make the answer to this question clear by reading them.

@SeungheonOh

Copy link
Copy Markdown
Collaborator Author

bindingAnchor is only used for profiling mode since we only need binding information for profiling. This is unless we want to add some binding information to error messages, but I'm not sure which error message would benefit from this extra information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No Changelog Required Add this to skip the Changelog Check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make profiling output include better source span

2 participants